package com.view;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.controller.UserManager;
import com.domain.AppUser;

@SuppressWarnings("serial")
public class ValidateUserServlet extends HttpServlet{
	private UserManager userManager = new UserManager();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req,resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String username = req.getParameter("Username");
		String password = req.getParameter("Password");
		
		AppUser validatingUser = new AppUser(username,password,null,null);
		if(userManager.isUserValid(validatingUser)){
			resp.getWriter().println(true);
		}else{
			resp.getWriter().println(false);
		}
	}

}
